<?php

$data = $this->calendardata;
$unit = $this->unit;

$criteria = RM_Reservation_Manager::getInstance()->getCriteria();

// get the config
$model = new RM_EnhancedCalendarConfig();
$settings = $model->getSettings()->toArray();
$settings = $settings[0];

// get price system
$config = new RM_Config;
$priceSystem = RM_Prices_Manager::getInstance()->getRealPriceSystem($this->unit);
$peopleMaximums = $priceSystem->getPeopleMaximums($unit->id); // returns array containing "max_occupancy"=>$max_occupancy,"max_adults"=>$max_adults,"max_children"=>$max_children,"max_infants"=>$max_infants
$showTime = $priceSystem->getShowTime(); // returns if the price system needs time values to be selected.
$calStartDate = "";
if (isset($criteria) && $criteria->start_datetime){
    $calStartDate = $criteria->start_datetime;
}
?>
<html>
<head>
<script type="text/javascript">
RM = {};
RM.Pages = {};
RM.Pages.User = {};
RM.Pages.User.Unit = {};
RM.Common = {};
RM.Common.GUIDateFormat = "<?php echo $this->guiDateFormat ?>";
RM.Common.MySQLDateFormat = "<?php echo $this->mysqlDateFormat ?>"; // yyyy-mm-dd
RM.Common.PHPDateFormat = "<?php echo $this->phpDateFormat ?>"; // yyyy-mm-dd hh:mm:ii
RM.Common.CalendarStartDay = <?php echo $this->calStartDay ?>;
RM.RootURL = '<?php echo RM_Environment::getConnector()->getRootURL(); ?>';

<?php echo $this->_router->getAccembleURLJsCode(); ?>

// calendar config
var show_day = <?php echo ($settings['show_day'] == "1" ? "true" : "false");?>;
var show_week = <?php echo ($settings['show_week'] == "1" ? "true" : "false");?>;
var show_twoweek = <?php echo ($settings['show_twoweek'] == "1" ? "true" : "false");?>;
var show_month = <?php echo ($settings['show_month'] == "1" ? "true" : "false");?>;
var read_only = <?php echo ($settings['read_only'] == "1" ? "true" : "false");?>;
var show_time = <?php echo ($showTime == "1" ? "true" : "false");?>;
var show_help_popup = <?php echo ($settings['showhelp_popup'] == "1" ? "true" : "false");?>;
var close_onselect = <?php echo ($settings['close_onselect'] == "1" ? "true" : "false");?>;
var fullday_starttime = "<?php echo $settings['fullday_starttime'];?>";
var fullday_endtime = "<?php echo $settings['fullday_endtime'];?>";
var calendarStartDate = "<?php echo $calStartDate;?>";
<?php if (is_array($peopleMaximums)){ ?>
    var adults = <?php echo ((int)$peopleMaximums['max_adults'] == 0 ? 1 : $peopleMaximums['max_adults']);?>;
    var children = <?php echo (int)$peopleMaximums['max_children'];?>;
    var infants = <?php echo (int)$peopleMaximums['max_infants'];?>;
    var maxOccupancy = <?php echo (int)$peopleMaximums['max_occupancy'];?>;
<?php } else { ?>
    var adults = 1;
    var children = 0;
    var infants = 0;
    var maxOccupancy = 1;
<?php } ?>
</script>

<?php
// set if the js files are loaded from debug or live(compressed)...
if ((int)Zend_Registry::get('config')->get('js')->get('debug')->get('user') == 1) {
    $jsLoadFolder = '/debug/';
} else {
    $jsLoadFolder = '/';
}
?>

<script type="text/javascript" src="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js<?php echo $jsLoadFolder;?>admin/common.js"></script>
<script type="text/javascript" src="<?php echo RM_Environment::getInstance()->getRouter()->_('Language', 'getconstants'); ?>"></script>


<!-- ExtJS CSS -->
<link rel="stylesheet" type="text/css" href="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/resources/css/ext-all.css"/>
<!--<link rel="stylesheet" type="text/css" href="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/resources/css/xtheme-blueen.css" id="theme">-->

<!-- ExtJS Base -->
<?php
$RMconfig = Zend_Registry::get('config');
if ((int)$RMconfig->get('js')->get('debug')->get('user') == 1) {
    ?>
    <script language="javascript" type='text/javascript' src='<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/adapter/ext/ext-base-debug.js'></script>
    <script type="text/javascript" src="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/ext-all-debug.js"></script>
    <?php
} else {
    ?><script language="javascript" type='text/javascript' src='<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/adapter/ext/ext-base.js'></script><?php
    if ((int)$RMconfig->get('gzip')->get('extjs') == 1) {
        ?><script type="text/javascript" src="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/ext-all.gz.js"></script><?php
    } else {
        ?><script type="text/javascript" src="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/ext-all.js"></script><?php
    }
}
?>
<!-- ExtJS CSS -->
<link rel="stylesheet" type="text/css" href="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/resources/css/ext-all.css"/>
<!--<link rel="stylesheet" type="text/css" href="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext/resources/css/xtheme-blueen.css" id="theme">-->

<!-- Extensible includes -->
<link rel="stylesheet" type="text/css" href="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext_addons/extensible/resources/css/extensible-all.css" />
<?php
// set if the js files are loaded from debug or live(compressed)...
if ((int)Zend_Registry::get('config')->get('js')->get('debug')->get('user') == 1) {
    ?>
    <script type="text/javascript" src="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext_addons/extensible/extensible-all-debug.js"></script>
    <?php
} else {
    ?>
    <script type="text/javascript" src="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext_addons/extensible/extensible-all.js"></script>
    <?php
}
?>
<!-- Any Extensible overrides go here -->

<!-- Page-specific includes -->
<link rel="stylesheet" type="text/css" href="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/system/js/libs/ext_addons/extensible/resources/css/calendar.css"/>

<script type="text/javascript" src="<?php echo RM_Environment::getConnector()->getRootURL(); ?>RM/userdata/modules/EnhancedCalendar/views/user/scripts/EnhancedCalendar/calendar.js"></script>

<!-- App -->
<script language="javascript">
var unitName = "<?php echo $unit->name;?>";
var unitID = "<?php echo $unit->id;?>";
</script>
<style type="text/css">
<!--
body {
    /* hide the scrollbars */
    overflow: hidden;
}
-->
</style>


</head>
<body>
    <div id="rm-enhanced-calendar-panel"></div>
</body>
</html>